package leetcode.easy;

import leetcode.base.TreeNode;

import java.util.LinkedList;
import java.util.List;

/**
 * ClassName: $145_PostorderTraversal
 * Description:
 * date: 2021-11-18 22:52
 *
 * @author liyifan
 */
public class $145_PostorderTraversal {
    public List<Integer> postorderTraversal(TreeNode root) {
        List<Integer> res = new LinkedList<>();
        dfs(root, res);
        return res;
    }

    private void dfs(TreeNode root, List<Integer> res) {
        if (root == null)
            return;
        dfs(root.left, res);
        dfs(root.right, res);
        res.add(root.val);
    }
}
